package com.cy.utils;

import com.cy.cfg.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @Author : 残影
 * @Date: 2020-09-11 10:02
 */
public class DataSourceUtil {
    /**
     * 获取连接
     * @param cfg
     * @return
     */
    public static Connection getConnection(Configuration cfg) {
        try {
            Class.forName(cfg.getDriver());
            Connection conn =
                    DriverManager.getConnection(cfg.getUrl(),cfg.getUsername() , cfg.getPassword());
            return conn;
        } catch (Exception e) {
            throw new RuntimeException(e);
        } }
}
